﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;

namespace EIBDDownloader
{
    public class CookieAwareWebClient : WebClient
    {
        CookieContainer cookies = new CookieContainer();

        public CookieContainer Cookies { get { return cookies; } set { cookies = value; } }

        protected override WebRequest GetWebRequest(Uri address)
        {

            WebRequest request = base.GetWebRequest(address);

            if (request.GetType() == typeof(HttpWebRequest))
                ((HttpWebRequest)request).CookieContainer = cookies;

            return request;

        }
    }

}
